#pragma once

#include <DirectXMath.h>
#include <array>
#include "Common.hpp"

#undef near
#undef far


struct BoundingFrustum
{
public:
    BoundingFrustum(DirectX::XMMATRIX proj);
    BoundingFrustum(float fovX, float aspect, float near, float far);

    static BoundingFrustum FromMatrix2(DirectX::XMMATRIX proj);

    //0: near 1: far 2: left  3: right 4: top 5: bottom
    void GenPlanes(std::array<DirectX::XMVECTOR, 6>& planes);

private:
    BoundingFrustum() = default;
    float m_leftSlope, m_rightSlope, m_topSlope, m_bottomSlope;
    float m_near, m_far;

public:

    DefGetter(m_leftSlope, LeftSlope)
    DefGetter(m_rightSlope, RightScope)
    DefGetter(m_topSlope, TopScope)
    DefGetter(m_bottomSlope, BottomScope)
    DefGetter(m_near, Near)
    DefGetter(m_far, Far)
};

void PlanesFromMatrix(DirectX::XMMATRIX projection, std::array<DirectX::XMVECTOR, 6>& planes);